import request from '@/utils/request'

export function init() {
  return request({
    url: '/agent/salesman/my_salesman_list',
    method: 'GET'
  })
}

export function search(date) {
  const data = {
    salesman_num: date.serial_number,
    name: date.name,
    contact_phone: date.contact_phone
  }

  return request({
    url: '/agent/salesman/my_salesman_list',
    method: 'GET',
    params: data
  })
}

export function del(salesman_num) {
  return request({
    url: '/agent/salesman/delete_salesman',
    method: 'DELETE',
    params: { salesman_num }
  })
}

export function page(page, form) {
  const data = {
    page,
    salesman_num: form.serial_number,
    name: form.name,
    phone: form.phone
  }

  return request({
    url: '/agent/salesman/my_salesman_list',
    method: 'GET',
    params: data
  })
}

export function salemanAdd(data) {
  return request({
    url: '/agent/salesman/add_salesman',
    method: 'POST',
    data
  })
}

export function salemanEditInit(salesman_num) {
  return request({
    url: 'agent/salesman/query_salesman',
    method: 'GET',
    params: { salesman_num }
  })
}

export function salemanEditSubmit(data) {
  return request({
    url: '/agent/salesman/edit_salesman',
    method: 'POST',
    data
  })
}
